package main

import "fmt"

func main() {

	var country = map[string]string{
		"china": "chengdu",
		"japan": "tokyo",
	}

	//city :=make(map[string]interface{})
	city := map[string]string{}
	city["name"] = "chengdu"
	fmt.Println(country)
	rating := map[string]float64{
		"c++":    5.0,
		"java":   7.0,
		"python": 8.0,
		"go":     9.0,
	}
	for key, value := range rating {
		fmt.Println("语言名字", key, "语言分数", value)

	}

	for key := range rating {
		fmt.Println("语言名字", key)
	}

	for _, value := range rating {
		fmt.Println("语言分数", value)
	}

	//检查元素是否存在
	value, ok := rating["go"]
	fmt.Println("go语言是否存在", ok, "存在的话,值是", value)
	if value, ok := rating["scala"]; ok {
		fmt.Println("scala语言存在,值是", value)

	} else {
		fmt.Println("没有找到scala语言")
	}

	value, ok = rating["kotlin"]
	fmt.Println("kotlin 语言存在", ok, "值是", value)
	//删除元素
	delete(rating, "c++")
	fmt.Println("删除后的rating", rating)

	//清空map
	country = map[string]string{}
	fmt.Println("清空后的country map == ", country)

	country = map[string]string{
		"china": "chengdu",
		"japan": "tokyo",
	}
	country["china"] = "beijing"
	fmt.Println("修改值后的country map == ", country)
}
